home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
js
/
loginCoverflow-src.js
< prev
next >
Wrap
Text File
|
2010-05-19
|
7KB
|
204 lines
var step=0,sub=10,hintCurrent,target,pos=0,dMask,dMaskSel,dMaskOff,dMaskPickDate,dMaskPickX,animTO=0;
function init(){
setPos(udSN)
if(users[pos]['reqUser']) dgi('loginUserInput').focus();
else if(users[pos]['password']) dgi('loginPasswordInput').focus();
wl.setKeycodeListener(dgi('loginUserInput'),userInputKD)
wl.setKeycodeListener(dgi('loginPasswordInput'),passwordInputKD,'onkeyup')
}
function userInputKD(kc,n,e){if(kc==13 && n.value) dgi('loginPasswordInput').focus();}
function passwordInputKD(kc,n,e){
if(kc==13 && n.value) login()
return;
if(e.shiftKey) shiftDown=1; else shiftDown=0;
if(kc>=65 && kc<=90) kc=n.value.charCodeAt(n.value.length-1)
if((kc>=65 && kc<=90 && !shiftDown) || (kc>=97 && kc<=123 && shiftDown)) capsLockShowWarning(n);
}
function resetInputs(){
if(dgi("encryptionLockSend")) dgi("encryptionLockSend").style.display="none";
dgi("loginPasswordInput").value="";
loginSetError('');
dgi("loginUserInput").value="";
wl.button.enable(dgi('loginBt'));
}
function loginSetError(txt){
dgi('loginError').innerHTML=txt;
fade(dgi('loginError'))
}
function login(){
var id=Math.round(pos);
if(users[id]['reqUser'] && !dgi('loginUserInput').value){
dgi('loginUserInput').focus();
return;
}
if(users[id]['password'] && !dgi('loginPasswordInput').value && !users[id]['reqUser']) {
dgi('loginPasswordInput').focus();
return;
}
wl.button.disable(dgi('loginBt'));
if(users[id]['reqUser']) logUserByName(dgi('loginUserInput').value,dgi('loginPasswordInput').value);
else logUserById(users[id]['id'],((users[id]['password'])?dgi('loginPasswordInput').value:false))
}
function goPos(p,noLog){
var dec=5;
if(p!==undefined) {
if((Math.abs(pos-p)<0.1 || p==target)&& !noLog) return login();
target=p;
}
wl.adaptedTimeoutValueStart()
if(Math.abs(pos-target)<0.03) pos=target;
setPos(target/dec+(dec-1)*pos/dec)
dgi('loginError').style.visibility='hidden';
if(pos!=target) animTO=setTimeout('goPos()',wl.adaptedTimeoutValue(25));
else {
animTO=0;
if(users[pos]['reqUser']) dgi('loginUserInput').focus();
else if(users[pos]['password']) dgi('loginPasswordInput').focus();
else dgi('noFocus').focus();
}
}
/**
* Return x coordinate of center of item number i for global position p. x
*/
function f(p,i){
return -(p-i)*58*(1+Math.exp(-(p-i)*(p-i)/10));
}
/**
* Invert f function
*/
function inv(x,i){
x+=66;
var l=0,u=nb-1,m,it=0;
if(f(l,i)<x) return (-Math.sqrt(Math.abs((x-f(l,i))/100)))
if(f(u,i)>x) return (u+Math.sqrt(Math.abs((x-f(u,i))/100)))
while(Math.abs(u-l)>0.01 && it<50){
m=(u+l)/2;
if(f(m,i)<x) u=m; else l=m;
it++;
}
return m;
}
/**
* Set position of all covers
* float p ranges from 0 to nb of items-1. p can be < 0 or > nb-1 if user goes out of bounds
*/
function setPos(p){
var i,l,u,hw,hh,sz,sel,h1,h2;
pos=p;
for(i=0;i<nb;i++){
sz=32*(1+1.5*Math.exp(-(p-i)*(p-i)/10));
w=Math.floor(133*sz/80);
hw=Math.floor(133*sz/160);
h=Math.floor(166*sz/80);
hh=Math.floor(166*sz/160);
x=f(p,i);
// Pos
with((n=dgi('l'+i)).style){left=(x-w/2)+"px"; zIndex=Math.round(sz); top=(-hh)+"px";}
if(w!=n.style.width){
// Div
with(n.style){width=w+"px";height=w+"px"}
// Mask
with((n=n.firstChild).style){width=w+"px"; height=h+"px";}
// Image
with((n=n.nextSibling).style){width=sz+"px"; height=sz+"px"; top=((w-sz)/2)+"px"; left=((w-sz)/2)+"px";}
// Label
n.nextSibling.style.fontSize=(100*sz/80)+'%'
}
}
l=Math.min(Math.max(Math.floor(p),0),nb-1)
u=Math.min(Math.max(Math.ceil(p),0),nb-1)
// password alpha & height
try{alpha=Math.min(1,(1-p+l)*users[l]['password']+(1-u+p)*users[u]['password']);} catch(err){alpha=1} // unknown error WA. To be fixed
setAlpha(dgi('loginPasswordLb'),alpha);
setAlpha(dgi('loginPasswordInput'),alpha);
dgi('loginPasswordGroup').style.height=(Math.max(1,(35*alpha)))+'px'
// user input alpha & height
if(!users[l]['reqUser']) users[l]['reqUser']=0;
if(!users[u]['reqUser']) users[u]['reqUser']=0;
alpha=Math.min(1,(1-p+l)*users[l]['reqUser']+(1-u+p)*users[u]['reqUser']);
setAlpha(dgi('loginUserLb'),alpha);
setAlpha(dgi('loginUserInput'),alpha);
dgi('loginUserGroup').style.height=(Math.max(1,(35*alpha)))+'px'
// Hint
if(p<0) l=u=p=0;
if(p>nb-1) l=u=p=nb-1;
alpha=Math.max(0,Math.min(1,(1-p+l-0.5)*((users[l]['hint'])?1:0)+(1-u+p-0.5)*((users[u]['hint'])?1:0)));
sel=Math.round(pos)
if(p==sel) h=(users[sel] && users[sel].hint)?users[sel].hint:'';
if(p-sel>0){
h1=(users[sel] && users[sel].hint)?users[sel].hint:'';
h2=(users[u] && users[u].hint)?users[u].hint:'';
h=h1.substr(Math.floor(h1.length*(1-u+p)))+''+h2.substr(0,Math.floor(h2.length*(1-u+p)));
if(h1&&h2) alpha=1;
}
if(p-sel<0){
h1=(users[l] && users[l].hint)?users[l].hint:'';
h2=(users[sel] && users[sel].hint)?users[sel].hint:'';
if(users[l])
h=h1.substr(Math.floor(h1.length*(p-l)))+''+h2.substr(0,Math.floor(h2.length*(p-l)));
else h=h2;
if(h1&&h2) alpha=1;
}
if(h!=hintCurrent) dgi('loginHint').innerHTML=hintCurrent=h;
if(phpBrowser=='ie') alpha=Math.ceil(alpha);
setAlpha(dgi('loginHintGroup'),alpha);
dgi('loginBox').style.height=(Math.max(0,(20*alpha)))+'px'
}
// Get item below mouse
function getItemBelowMouse(){
var n,l,t,it=-1,i,maxZ=-999;
for(i=0;i<nb;i++){
n=dgi('l'+i);
l=actualOffsetLeft(n); t=actualOffsetTop(n);
if(l<=mouseX && l+n.offsetWidth>=mouseX && t<=mouseY && t+n.offsetHeight>=mouseY){
if(n.style.zIndex>maxZ){maxZ=n.style.zIndex; it=i}
}
}
return it;
}
// Called on mouse down on mask
function dMaskPick(e){
dMaskPickDate=wl.chrono.microtime();
dMaskPickX=mouseX;
dMaskSel=getItemBelowMouse();
if(dMaskSel==-1) return;
if(animTO) W.clearTimeout(animTO);
animTO=0;
dMaskOff=mouseX-actualOffsetLeft(dgi('l'+dMaskSel));
var p=inv(mouseX+0-actualOffsetLeft(dgi('loginCenterPos'))-dMaskOff,dMaskSel);
}
function dMaskDrag(e){
if(dMaskSel==-1) return;
setPos(inv(mouseX-actualOffsetLeft(dgi('loginCenterPos'))-dMaskOff,dMaskSel))
}
// Click / drop
function dMaskDrop(){
if(dMaskSel==-1) return;
// Click
if((wl.chrono.microtime()-dMaskPickDate)<300 && Math.abs(mouseX-dMaskPickX)<6) {
goPos(dMaskSel)
}
// Drop
else{
var p;
if(pos>nb-1) p=Math.ceil(nb-1-(pos-nb+1)/1.5);
else if(pos<0) p=Math.floor(-pos/1.5);
else p=Math.round(inv(mouseX+mouseVX/10-actualOffsetLeft(dgi('loginCenterPos'))-dMaskOff,dMaskSel))
p=Math.min(Math.max(p,0),nb-1)
goPos(p,1)
}
dMaskSel=-1;
}
/**
* Called by wz_dragdrop.js on object drop (after a click on a coverflow item)
*/
function preDrop(){dMaskDrop()}